﻿

(function ($) {

    $.fn.recaptcha = function (o) {

        var defaults = {
            publicKey: '6LfV3MISAAAAAMfrkyDzhYZNkjR3YlyOC_YlIfn_',
            theme: 'red',
            callback: function () { }
        };

        var _this = this;

        if (_this.length > 0) {
            if (typeof Recaptcha == "undefined") {

                $.getScript('http://www.google.com/recaptcha/api/js/recaptcha_ajax.js', function () {

                    _this.recaptcha(o);
                });

                return false;

            }


            return this.each(function () {

                var m = $(this);

                var s = $.extend({}, defaults, o || {}, $.metadata ? m.metadata() : $.meta ? m.data() : {});

                var id = m.attr('id');
                if (id === undefined) {
                    id = 'recapcha_' + new Date().getTime();
                    m.attr('id', id);
                }

                window.Recaptcha.create(s.publicKey, id, {
                    theme: s.theme,
                    callback: s.callback
                });

            });
        }
        return false;
    };

})(jQuery);